{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "854609e8",
   "metadata": {},
   "source": [
    "## 本周知识点\n",
    "### 1.字典的初始 （{key:value})\n",
    "> 1.[字典的文档](https://docs.python.org/3/tutorial/datastructures.html#dictionaries)  \n",
    "> 2.字典的重要属性:\n",
    ">> 1.结构：key:value(键值对)  \n",
    ">> 2.字典是无序的，我们通过键（key）去查找（value）,就好像list用索引（index）直接查找值（value）一样，只不过字典的“索引”被定义了名字  \n",
    ">> 3.字典对key的定义有一定的要求：key是由“不可变”的数据才可以定义，list是不能作为key来定义的。  \n",
    ">> 4.字典的key是唯一的，字典的值value也可以不唯一。（list的值是唯一的么？）  \n",
    "\n",
    "> 3.字典的创建:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "e7aa3ebb",
   "metadata": {},
   "outputs": [],
   "source": [
    "users = [\n",
    "    [\"zhichao\",23,\"IT\",20000],\n",
    "    [\"junbin\",21,\"IT\",30000]\n",
    "]\n",
    "# 试对比：\n",
    "users_dict = {\n",
    "    \"zhichao\":[23,\"IT\",20000],\n",
    "    \"junbin\":[21,\"IT\",30000]\n",
    "}\n",
    "# 值与值之间都是用逗号隔开的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "054cb9c9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['junbin', 21, 'IT', 30000]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 查询junbin的信息：\n",
    "users[1]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "752d17b9",
   "metadata": {},
   "source": [
    "### 2.字典的创建（常见的三种创建方式）\n",
    "> 1.info = {key1:value , key2:value2 , ...}直接按照字典格式创建  \n",
    "> 2.info_02 = dict(key1=value1 , key2=value2 , ...)  \n",
    "> 3.运用字典增加的方式新建字典  \n",
    "```\n",
    "info_03 = {} info_03[key1] = value1 , info_03[key2] = value2...\n",
    "\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "06067ab2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "d085b32e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu10001': 'li', 'stu10002': 'kaijun', 'stu10003': 'lihaha'}\n",
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "info = {\n",
    "    \"stu10001\":\"guosiwen\",\n",
    "    \"stu10002\":\"kaijun\",\n",
    "    \"stu10003\":\"lihaha\",\n",
    "    \"stu10001\":\"li\" # 新的值会替代前面的值\n",
    "}\n",
    "print(info)\n",
    "print(type(info))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "c1eff265",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu10001': 'guosiwen', 'stu10002': 'kaijun', 'stu10003': 'lihaha'}\n",
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "info_02 = dict(\n",
    "    stu10001=\"guosiwen\",\n",
    "    stu10002=\"kaijun\",\n",
    "    stu10003=\"lihaha\",\n",
    ")\n",
    "print(info_02)\n",
    "print(type(info_02))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "848ee333",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu10001': 'guosiwen', 'stu10002': 'kaijun', 'stu10003': 'jiangjie'}\n",
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "info_03 ={} # 新建字典\n",
    "info_03[\"stu10001\"] = \"guosiwen\"\n",
    "info_03[\"stu10002\"] = \"kaijun\"\n",
    "info_03[\"stu10003\"] = \"jiangjie\"\n",
    "print(info_03)\n",
    "print(type(info_03))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ea3ca506",
   "metadata": {},
   "source": [
    "### 字典的增、删、改、查\n",
    "> 1.字典的增加:  \n",
    ">> * info_03[\"stu10004\"]=\"guosiwen\"\n",
    "> 2.字典的查询  \n",
    ">> *注意：正确的查询方式，应该先查询key是否存在在字典当中，如下  \n",
    ">>> 1.key_name in info_03 ## 查看是否存在，如果存在，返回结果为True,不存在，返回结果为False    \n",
    ">>> 2.info_03[key_name]  \n",
    "> 3.字典的修改  \n",
    ">> 1.查询key是否存在\n",
    ">> 2.修改key的值  \n",
    ">>> * 例如：修改info_03中的stu10003的值为ALex,if\"stu10003\"in info_03:info——03[\"stu10003\"]=\"Alex\"\n",
    "> 4.字典的删除\n",
    ">> 1.pop(key)  \n",
    ">> 2.popitem()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "23ac849b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu10001': 'guosiwen', 'stu10002': 'kaijun', 'stu10003': 'jiangjie', 'stu10004': 'guosiwen'}\n"
     ]
    }
   ],
   "source": [
    "info_03 [\"stu10004\"] = \"guosiwen\"\n",
    "print(info_03)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "18c212ad",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'jiangjie'"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 用key查到value的数据\n",
    "info_03[\"stu10003\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "935e723b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n",
      "查询的key不存在\n"
     ]
    }
   ],
   "source": [
    "print(\"stu10003\" in info_03)\n",
    "if \"stu10006\" in info_03:\n",
    "    print(info_03[\"stu10006\"])\n",
    "else:\n",
    "    print(\"查询的key不存在\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "9118a662",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu10001': 'guosiwen', 'stu10002': 'Alex', 'stu10003': 'lihaha'}\n"
     ]
    }
   ],
   "source": [
    "# 修改：也要先查询key\n",
    "if \"stu10002\" in info_02:\n",
    "    info_02[\"stu10002\"] = \"Alex\"\n",
    "print(info_02)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "736624d1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu10001': 'guosiwen', 'stu10002': 'Alex'}\n"
     ]
    }
   ],
   "source": [
    "# 字典的删除  \n",
    "info_02.pop(\"stu10003\")\n",
    "print(info_02)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "12771a5f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu10001': 'guosiwen'}\n"
     ]
    }
   ],
   "source": [
    "# 字典的删除popitem()\n",
    "info_02.popitem()\n",
    "print(info_02)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "214986b6",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院 = {'status': '1',\n",
    " 'regeocode': {'roads': [{'id': '020F49F0050461206',\n",
    "    'location': '113.678,23.6284',\n",
    "    'direction': '北',\n",
    "    'name': '博学路',\n",
    "    'distance': '7.63232'},\n",
    "   {'id': '020F49F0050462229',\n",
    "    'location': '113.679,23.6245',\n",
    "    'direction': '北',\n",
    "    'name': '老虎形街',\n",
    "    'distance': '445.159'},\n",
    "   {'id': '020F49F0050462451',\n",
    "    'location': '113.677,23.6347',\n",
    "    'direction': '南',\n",
    "    'name': '中山路',\n",
    "    'distance': '708.299'}],\n",
    "  'roadinters': [{'second_name': '中山路',\n",
    "    'first_id': '020F49F0050461206',\n",
    "    'second_id': '020F49F0050462451',\n",
    "    'location': '113.676794,23.634661',\n",
    "    'distance': '708.299',\n",
    "    'first_name': '博学路',\n",
    "    'direction': '南'}],\n",
    "  'formatted_address': '广东省广州市从化区温泉镇博学路',\n",
    "  'addressComponent': {'city': '广州市',\n",
    "   'province': '广东省',\n",
    "   'adcode': '440117',\n",
    "   'district': '从化区',\n",
    "   'towncode': '440117100000',\n",
    "   'streetNumber': {'number': '24号',\n",
    "    'location': '113.677267,23.629149',\n",
    "    'direction': '西北',\n",
    "    'distance': '129.943',\n",
    "    'street': '博学路'},\n",
    "   'country': '中国',\n",
    "   'township': '温泉镇',\n",
    "   'businessAreas': [[]],\n",
    "   'building': {'name': [], 'type': []},\n",
    "   'neighborhood': {'name': [], 'type': []},\n",
    "   'citycode': '020'},\n",
    "  'aois': [],\n",
    "  'pois': [{'id': 'B0FFG4TAF2',\n",
    "    'direction': '东南',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉镇乌土村松浪队5号(近博学路)',\n",
    "    'poiweight': '0.237309',\n",
    "    'name': '广州南方公寓',\n",
    "    'location': '113.678983,23.627778',\n",
    "    'distance': '102.617',\n",
    "    'tel': '13622768437',\n",
    "    'type': '商务住宅;住宅区;住宅小区'},\n",
    "   {'id': 'B0H6FA18J5',\n",
    "    'direction': '东南',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院南侧)',\n",
    "    'poiweight': '0.223065',\n",
    "    'name': '保利半山花园',\n",
    "    'location': '113.679358,23.627672',\n",
    "    'distance': '139.054',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;住宅区'},\n",
    "   {'id': 'B00140TWHT',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '笃行路2',\n",
    "    'poiweight': '0.157653',\n",
    "    'name': '教工住宅1号',\n",
    "    'location': '113.678490,23.630432',\n",
    "    'distance': '222.658',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;住宅小区'},\n",
    "   {'id': 'B0FFHRJDM9',\n",
    "    'direction': '东南',\n",
    "    'businessarea': [],\n",
    "    'address': '中大南方学院南门1号',\n",
    "    'poiweight': '0.256152',\n",
    "    'name': '中南公寓',\n",
    "    'location': '113.680349,23.627573',\n",
    "    'distance': '231.723',\n",
    "    'tel': '13711245345',\n",
    "    'type': '商务住宅;住宅区;住宅小区'},\n",
    "   {'id': 'B0HGD588HJ',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼4号',\n",
    "    'location': '113.677460,23.630490',\n",
    "    'distance': '242.901',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFHZH0IK',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路广州南方学院综合楼内',\n",
    "    'poiweight': '0.17934',\n",
    "    'name': '地下铁',\n",
    "    'location': '113.677941,23.629029',\n",
    "    'distance': '74.1376',\n",
    "    'tel': [],\n",
    "    'type': '餐饮服务;冷饮店;冷饮店'},\n",
    "   {'id': 'B0HGDU76L2',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院2号实验楼',\n",
    "    'location': '113.678211,23.630956',\n",
    "    'distance': '280.003',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFKP838K',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路25',\n",
    "    'poiweight': '0.191742',\n",
    "    'name': '教学楼3号(外国语学院)',\n",
    "    'location': '113.677247,23.630947',\n",
    "    'distance': '298.093',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;高等院校'},\n",
    "   {'id': 'B0HGDU8NLD',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路附近',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院1号实验楼',\n",
    "    'location': '113.678215,23.631370',\n",
    "    'distance': '326.007',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD58UTU',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.191229',\n",
    "    'name': '广州南方学院2号教学楼',\n",
    "    'location': '113.677060,23.631346',\n",
    "    'distance': '346.352',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B00140MR9A',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号',\n",
    "    'poiweight': '0.450402',\n",
    "    'name': '广州南方学院',\n",
    "    'location': '113.679262,23.632583',\n",
    "    'distance': '471.564',\n",
    "    'tel': '020-87828988;020-61787331',\n",
    "    'type': '科教文化服务;学校;高等院校'},\n",
    "   {'id': 'B0HGDU92JD',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': [],\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼1号',\n",
    "    'location': '113.677077,23.631783',\n",
    "    'distance': '391.548',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD592BJ',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道886号广州南方学院内',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院综合楼',\n",
    "    'location': '113.680117,23.631544',\n",
    "    'distance': '392.731',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFKP81F0',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路19号附近',\n",
    "    'poiweight': '0.191742',\n",
    "    'name': '教学楼1号(文学与传媒学院)',\n",
    "    'location': '113.676866,23.631736',\n",
    "    'distance': '393.93',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
    "   {'id': 'B0FFLBEOND',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院)',\n",
    "    'poiweight': '0.190963',\n",
    "    'name': '聚贤楼10号',\n",
    "    'location': '113.681253,23.631036',\n",
    "    'distance': '418.51',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;宿舍'},\n",
    "   {'id': 'B0FFH6K3U9',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉镇温泉大道882号广州南方学院H7栋1-5层',\n",
    "    'poiweight': '0.254885',\n",
    "    'name': '广州中大南方招待所',\n",
    "    'location': '113.676330,23.631332',\n",
    "    'distance': '378.102',\n",
    "    'tel': '020-61787222',\n",
    "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
    "   {'id': 'B0HGD58NF8',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院新综合楼2层',\n",
    "    'poiweight': '0.191229',\n",
    "    'name': '广州南方学院达人书院',\n",
    "    'location': '113.679041,23.632392',\n",
    "    'distance': '446.366',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
    "   {'id': 'B0FFKUVYWV',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '保利桃花源',\n",
    "    'poiweight': '0.273168',\n",
    "    'name': '广州和风庭阿七度假别墅',\n",
    "    'location': '113.681736,23.630569',\n",
    "    'distance': '424.35',\n",
    "    'tel': '18681565305',\n",
    "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
    "   {'id': 'B0HGDU99RM',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院内',\n",
    "    'poiweight': '0.257947',\n",
    "    'name': '广州南方学院图书馆',\n",
    "    'location': '113.679177,23.632762',\n",
    "    'distance': '489.331',\n",
    "    'tel': '020-61787368;020-61787371',\n",
    "    'type': '科教文化服务;图书馆;图书馆'},\n",
    "   {'id': 'B0HGDU92JC',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路附近',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院4号实验楼',\n",
    "    'location': '113.679963,23.632652',\n",
    "    'distance': '498.883',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFL7C054',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉镇博学路882号(广州南方学院商业中心1层)',\n",
    "    'poiweight': '0.317505',\n",
    "    'name': '广州U优森特酒店',\n",
    "    'location': '113.679226,23.632528',\n",
    "    'distance': '464.819',\n",
    "    'tel': '15813395296',\n",
    "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
    "   {'id': 'B0FFG8CSEK',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院)',\n",
    "    'poiweight': '0.185371',\n",
    "    'name': 'L5员工宿舍',\n",
    "    'location': '113.682583,23.631487',\n",
    "    'distance': '554.129',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;宿舍'},\n",
    "   {'id': 'B0HGD58FR2',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '广州南方学院',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼9号',\n",
    "    'location': '113.679747,23.633032',\n",
    "    'distance': '532.163',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HG5Z9JNK',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.221553',\n",
    "    'name': '广州南方学院教学楼7号',\n",
    "    'location': '113.678600,23.633330',\n",
    "    'distance': '544.868',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD599JM',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院第11教学楼',\n",
    "    'location': '113.680037,23.633173',\n",
    "    'distance': '556.036',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0GUJYPEG2',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院内博学路6号之3',\n",
    "    'poiweight': '0.216026',\n",
    "    'name': '怒烤烤串(从化店)',\n",
    "    'location': '113.677160,23.632910',\n",
    "    'distance': '510.112',\n",
    "    'tel': [],\n",
    "    'type': '餐饮服务;中餐厅;特色/地方风味餐厅'},\n",
    "   {'id': 'B0HGDU6Z41',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼6号',\n",
    "    'location': '113.678424,23.633710',\n",
    "    'distance': '586.331',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD580NZ',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路7号附近',\n",
    "    'poiweight': '0.285712',\n",
    "    'name': '广州南方学院惟贤门',\n",
    "    'location': '113.678437,23.633721',\n",
    "    'distance': '587.601',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;高等院校'},\n",
    "   {'id': 'B0HGDU7T1K',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院)',\n",
    "    'poiweight': '0.191229',\n",
    "    'name': '广州南方学院教学楼10号',\n",
    "    'location': '113.680125,23.633492',\n",
    "    'distance': '592.504',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
    "   {'id': 'B0HGDU76L1',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '中山路与博学路交叉口东南150米',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼5号',\n",
    "    'location': '113.678046,23.633982',\n",
    "    'distance': '616.848',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'}]},\n",
    " 'info': 'OK',\n",
    " 'infocode': '10000'}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "id": "cfae0312",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 取出教工住宅1号的信息\n",
    "教工住宅1号_name = 广州南方学院['regeocode']['pois'][2]['name']\n",
    "教工住宅1号_address = 广州南方学院['regeocode']['pois'][2]['address']\n",
    "教工住宅1号_location = 广州南方学院['regeocode']['pois'][2]['location']\n",
    "教工住宅1号_type = 广州南方学院['regeocode']['pois'][2]['type']\n",
    "教工住宅1号_direction = 广州南方学院['regeocode']['pois'][2]['direction']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "f8d58b22",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "教工住宅1号\n",
      "笃行路2\n",
      "113.678490,23.630432\n",
      "商务住宅;住宅区;住宅小区\n",
      "北\n"
     ]
    }
   ],
   "source": [
    "print(教工住宅1号_name)\n",
    "print(教工住宅1号_address)\n",
    "print(教工住宅1号_location)\n",
    "print(教工住宅1号_type)\n",
    "print(教工住宅1号_direction)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c29cf411",
   "metadata": {},
   "source": [
    "#### 请完成如下字典操作和列表操作的目标：\n",
    "\n",
    "* 1. 取出一个'roads'\n",
    "* 2. 取出一个'roads' 的 'name' 道路名字\n",
    "* 3. 取出一个'roads' 的 'direction' 路的朝向\n",
    "\n",
    "-----\n",
    "* 进阶：\n",
    "* 4. 取出对应的 pois name 所对应的 name 并存成一个list 如name_list = [...]\n",
    "* 5. 取出所有的 pois name 以及其对应的 信息 并分别存成对应的list 如name_location_list = [...]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "id": "5be24c16",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 取出一个'roads'\n",
    "随便一条_road = 广州南方学院['regeocode']['roads'][1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "366d7904",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'id': '020F49F0050462229', 'location': '113.679,23.6245', 'direction': '北', 'name': '老虎形街', 'distance': '445.159'}\n"
     ]
    }
   ],
   "source": [
    "print(随便一条_road)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "34da2ad7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 取出博学路的信息(name+direction)\n",
    "博学路_name = 广州南方学院['regeocode']['roads'][0]['name']\n",
    "博学路_direction = 广州南方学院['regeocode']['roads'][0]['direction']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "id": "c56f627c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "博学路\n",
      "北\n"
     ]
    }
   ],
   "source": [
    "print(博学路_name)\n",
    "print(博学路_direction)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "id": "ff144b2d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "保利半山花园\n"
     ]
    }
   ],
   "source": [
    "# 进阶练习\n",
    "pois_name = 广州南方学院['regeocode']['pois'][1]['name']\n",
    "print(pois_name)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "id": "b0de92db",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'广州南方公寓': '113.678983,23.627778'},\n",
       " {'保利半山花园': '113.679358,23.627672'},\n",
       " {'教工住宅1号': '113.678490,23.630432'},\n",
       " {'中南公寓': '113.680349,23.627573'},\n",
       " {'广州南方学院教学楼4号': '113.677460,23.630490'},\n",
       " {'地下铁': '113.677941,23.629029'},\n",
       " {'广州南方学院2号实验楼': '113.678211,23.630956'},\n",
       " {'教学楼3号(外国语学院)': '113.677247,23.630947'},\n",
       " {'广州南方学院1号实验楼': '113.678215,23.631370'},\n",
       " {'广州南方学院2号教学楼': '113.677060,23.631346'},\n",
       " {'广州南方学院': '113.679262,23.632583'},\n",
       " {'广州南方学院教学楼1号': '113.677077,23.631783'},\n",
       " {'广州南方学院综合楼': '113.680117,23.631544'},\n",
       " {'教学楼1号(文学与传媒学院)': '113.676866,23.631736'},\n",
       " {'聚贤楼10号': '113.681253,23.631036'},\n",
       " {'广州中大南方招待所': '113.676330,23.631332'},\n",
       " {'广州南方学院达人书院': '113.679041,23.632392'},\n",
       " {'广州和风庭阿七度假别墅': '113.681736,23.630569'},\n",
       " {'广州南方学院图书馆': '113.679177,23.632762'},\n",
       " {'广州南方学院4号实验楼': '113.679963,23.632652'},\n",
       " {'广州U优森特酒店': '113.679226,23.632528'},\n",
       " {'L5员工宿舍': '113.682583,23.631487'},\n",
       " {'广州南方学院教学楼9号': '113.679747,23.633032'},\n",
       " {'广州南方学院教学楼7号': '113.678600,23.633330'},\n",
       " {'广州南方学院第11教学楼': '113.680037,23.633173'},\n",
       " {'怒烤烤串(从化店)': '113.677160,23.632910'},\n",
       " {'广州南方学院教学楼6号': '113.678424,23.633710'},\n",
       " {'广州南方学院惟贤门': '113.678437,23.633721'},\n",
       " {'广州南方学院教学楼10号': '113.680125,23.633492'},\n",
       " {'广州南方学院教学楼5号': '113.678046,23.633982'}]"
      ]
     },
     "execution_count": 152,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 进阶4\n",
    "# 新建一个name_list空列表，2.利用循环遍历【pois】3.最后将name添加到列表中\n",
    "name_list = []\n",
    "for i in dict['regeocode']['pois']:\n",
    "    name_list.append(i['name'])\n",
    "name_location_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 156,
   "id": "796e62f7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'广州南方公寓': '113.678983,23.627778'},\n",
       " {'保利半山花园': '113.679358,23.627672'},\n",
       " {'教工住宅1号': '113.678490,23.630432'},\n",
       " {'中南公寓': '113.680349,23.627573'},\n",
       " {'广州南方学院教学楼4号': '113.677460,23.630490'},\n",
       " {'地下铁': '113.677941,23.629029'},\n",
       " {'广州南方学院2号实验楼': '113.678211,23.630956'},\n",
       " {'教学楼3号(外国语学院)': '113.677247,23.630947'},\n",
       " {'广州南方学院1号实验楼': '113.678215,23.631370'},\n",
       " {'广州南方学院2号教学楼': '113.677060,23.631346'},\n",
       " {'广州南方学院': '113.679262,23.632583'},\n",
       " {'广州南方学院教学楼1号': '113.677077,23.631783'},\n",
       " {'广州南方学院综合楼': '113.680117,23.631544'},\n",
       " {'教学楼1号(文学与传媒学院)': '113.676866,23.631736'},\n",
       " {'聚贤楼10号': '113.681253,23.631036'},\n",
       " {'广州中大南方招待所': '113.676330,23.631332'},\n",
       " {'广州南方学院达人书院': '113.679041,23.632392'},\n",
       " {'广州和风庭阿七度假别墅': '113.681736,23.630569'},\n",
       " {'广州南方学院图书馆': '113.679177,23.632762'},\n",
       " {'广州南方学院4号实验楼': '113.679963,23.632652'},\n",
       " {'广州U优森特酒店': '113.679226,23.632528'},\n",
       " {'L5员工宿舍': '113.682583,23.631487'},\n",
       " {'广州南方学院教学楼9号': '113.679747,23.633032'},\n",
       " {'广州南方学院教学楼7号': '113.678600,23.633330'},\n",
       " {'广州南方学院第11教学楼': '113.680037,23.633173'},\n",
       " {'怒烤烤串(从化店)': '113.677160,23.632910'},\n",
       " {'广州南方学院教学楼6号': '113.678424,23.633710'},\n",
       " {'广州南方学院惟贤门': '113.678437,23.633721'},\n",
       " {'广州南方学院教学楼10号': '113.680125,23.633492'},\n",
       " {'广州南方学院教学楼5号': '113.678046,23.633982'}]"
      ]
     },
     "execution_count": 156,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict_temporary = {}\n",
    "name_location_list = []\n",
    "for i in dict['regeocode']['pois']:\n",
    "    dict_temporary = {i['name']:i['location']}\n",
    "    name_location_list.append(dict_temporary)\n",
    "    \n",
    "name_location_list"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
